package net.bezrabotnih.client.managed.activity;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceController;
import com.google.inject.Inject;

import net.bezrabotnih.client.scaffold.place.ProxyListPlace;
import net.bezrabotnih.client.managed.request.ApplicationRequestFactory;
import net.bezrabotnih.client.managed.request.ApplicationEntityTypesProcessor;
import net.bezrabotnih.client.scaffold.ScaffoldApp;
import net.bezrabotnih.client.managed.activity.UserRatingListActivity;
import net.bezrabotnih.client.managed.request.UserRatingProxy;
import net.bezrabotnih.client.managed.ui.UserRatingListView;
import net.bezrabotnih.client.managed.ui.UserRatingMobileListView;
import net.bezrabotnih.client.managed.activity.UserAccountListActivity;
import net.bezrabotnih.client.managed.request.UserAccountProxy;
import net.bezrabotnih.client.managed.ui.UserAccountListView;
import net.bezrabotnih.client.managed.ui.UserAccountMobileListView;


import net.bezrabotnih.client.managed.activity.ThumbnailListActivity;
import net.bezrabotnih.client.managed.request.ThumbnailProxy;
import net.bezrabotnih.client.managed.ui.ThumbnailListView;
import net.bezrabotnih.client.managed.ui.ThumbnailMobileListView;
import net.bezrabotnih.client.managed.activity.PhotoListActivity;
import net.bezrabotnih.client.managed.request.PhotoProxy;
import net.bezrabotnih.client.managed.ui.PhotoListView;
import net.bezrabotnih.client.managed.ui.PhotoMobileListView;
import net.bezrabotnih.client.managed.activity.LoginActionListActivity;
import net.bezrabotnih.client.managed.request.LoginActionProxy;
import net.bezrabotnih.client.managed.ui.LoginActionListView;
import net.bezrabotnih.client.managed.ui.LoginActionMobileListView;
import net.bezrabotnih.client.managed.activity.JobTypeListActivity;
import net.bezrabotnih.client.managed.request.JobTypeProxy;
import net.bezrabotnih.client.managed.ui.JobTypeListView;
import net.bezrabotnih.client.managed.ui.JobTypeMobileListView;
import net.bezrabotnih.client.managed.activity.JobListActivity;
import net.bezrabotnih.client.managed.request.JobProxy;
import net.bezrabotnih.client.managed.ui.JobListView;
import net.bezrabotnih.client.managed.ui.JobMobileListView;
import net.bezrabotnih.client.managed.activity.CommentListActivity;
import net.bezrabotnih.client.managed.request.CommentProxy;
import net.bezrabotnih.client.managed.ui.CommentListView;
import net.bezrabotnih.client.managed.ui.CommentMobileListView;

/**
 * Instantiates master activities.
 */
public final class ApplicationMasterActivities implements ActivityMapper {
	private final ApplicationRequestFactory requests;
	private final PlaceController placeController;

	@Inject
	public ApplicationMasterActivities(ApplicationRequestFactory requests, PlaceController placeController) {
 		this.requests = requests;
		this.placeController = placeController;
	}

	public Activity getActivity(Place place) {
		if (!(place instanceof ProxyListPlace)) {
			return null;
		}

		ProxyListPlace listPlace = (ProxyListPlace) place;

		return new ApplicationEntityTypesProcessor<Activity>() {
			@Override
      public void handleUserRating(UserRatingProxy isNull) {
        setResult(new UserRatingListActivity(requests,
          ScaffoldApp.isMobile() ? UserRatingMobileListView.instance() : UserRatingListView.instance(),
          placeController));
      }
      
			@Override
      public void handleUserAccount(UserAccountProxy isNull) {
        setResult(new UserAccountListActivity(requests,
          ScaffoldApp.isMobile() ? UserAccountMobileListView.instance() : UserAccountListView.instance(),
          placeController));
      }
      
	
      
			@Override
      public void handleThumbnail(ThumbnailProxy isNull) {
        setResult(new ThumbnailListActivity(requests,
          ScaffoldApp.isMobile() ? ThumbnailMobileListView.instance() : ThumbnailListView.instance(),
          placeController));
      }
      
			@Override
      public void handlePhoto(PhotoProxy isNull) {
        setResult(new PhotoListActivity(requests,
          ScaffoldApp.isMobile() ? PhotoMobileListView.instance() : PhotoListView.instance(),
          placeController));
      }
      
			@Override
      public void handleLoginAction(LoginActionProxy isNull) {
        setResult(new LoginActionListActivity(requests,
          ScaffoldApp.isMobile() ? LoginActionMobileListView.instance() : LoginActionListView.instance(),
          placeController));
      }
      
			@Override
      public void handleJobType(JobTypeProxy isNull) {
        setResult(new JobTypeListActivity(requests,
          ScaffoldApp.isMobile() ? JobTypeMobileListView.instance() : JobTypeListView.instance(),
          placeController));
      }
      
			@Override
      public void handleJob(JobProxy isNull) {
        setResult(new JobListActivity(requests,
          ScaffoldApp.isMobile() ? JobMobileListView.instance() : JobListView.instance(),
          placeController));
      }
      
			@Override
      public void handleComment(CommentProxy isNull) {
        setResult(new CommentListActivity(requests,
          ScaffoldApp.isMobile() ? CommentMobileListView.instance() : CommentListView.instance(),
          placeController));
      }
      
		}.process(listPlace.getProxyClass());
	}
}
